package base.day14.service;

import base.day14.dao.TeacherDao;
import base.day14.domain.Teacher;

public class TeacherService {
    TeacherDao td=new TeacherDao();


    public boolean addTeacher(Teacher teacher) {
        return td.addTeacher(teacher);
    }

    public boolean isExists(String id) {
        Teacher[] teas=td.findAllTeacher();
        boolean flag=false;
        for (int i = 0; i < teas.length; i++) {
            Teacher tea=teas[i];
            if (tea!=null&&tea.getId().equals(id)){
                flag=true;
                break;
            }
        }
        return flag;
    }

    public Teacher[] findAllStudent() {
        Teacher[] teas=td.findAllTeacher();
        boolean flag=false;
        for (int i = 0; i < teas.length; i++) {
            Teacher tea=teas[i];
            if (tea!=null){
                flag=true;
                break;
            }
        }
        if (flag){
            return teas;
        }else {
            return null;
        }
    }

    public void deleteTeacherById(String deid) {
        td.deleteTeacherById(deid);
    }

    public void upDateTeacher(String upid, Teacher teacher) {
        td.upDateTeacher(upid,teacher);
    }
}
